home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / DTS.Draw / TGroupObj.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  4.0 KB  |  151 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        TGroupObj.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1992 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* See the files "=How to write your app" and "=Using TreeObj.c" for information
  12. ** on this function. */
  13.  
  14. /* The group object is used as a parent of objects that are to be grouped.
  15. ** By having a group parent object, the children are understood to be grouped.
  16. ** This allows a hierarchy of groups.
  17. **
  18. ** Group objects can't be clicked on.  Their members can, however.  This means
  19. ** that hit-testing for a group always returns false.  When an actual object is
  20. ** hit, it actually returns itself only if the parent isn't a group.  A hit on
  21. ** an actual object causes the object to look at the parent.  If the parent is
  22. ** a group, then it wants to return the parent as the object hit.  If in turn that
  23. ** parent is a group, it continues up the chain until a non-group object is hit.
  24. ** For this sample application the first non-group parent will always be the root
  25. ** object.
  26. **
  27. ** The above parent check for hit-testing means that the highest order object
  28. ** in the group will always be returned, thus indicating that all members of the
  29. ** group should be considered selected.  That is the exact implementation we use.
  30. **
  31. ** This also means that only objects directly off the root can be selected.  The
  32. ** object will either be the highest order group object, or it will be an actual
  33. ** object directly off the root.
  34. **
  35. ** It seems kind of odd that a group object can be selected, but it can't be hit.
  36. ** This does actually make sense, since if any one of the members of the group is
  37. ** hit, the entire group should be considered a single entity, and the highest
  38. ** order group object would then naturally be the object to select. */
  39.  
  40.  
  41.  
  42. /*****************************************************************************/
  43.  
  44.  
  45.  
  46. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  47. #include "App.Common.h"        /* Get the stuff in common with rez.            */
  48. #include "App.protos.h"        /* Get the prototypes for the application.        */
  49.  
  50. #ifndef __OSEVENTS__
  51. #include <OSEvents.h>
  52. #endif
  53.  
  54. #ifndef __OSUTILS__
  55. #include <OSUtils.h>
  56. #endif
  57.  
  58. #ifndef __QUICKDRAW__
  59. #include <Quickdraw.h>
  60. #endif
  61.  
  62. #ifndef __STRING__
  63. #include <String.h>
  64. #endif
  65.  
  66. #ifndef __TREEOBJ2__
  67. #include "TreeObj2.h"
  68. #endif
  69.  
  70. #ifndef __UTILITIES__
  71. #include "Utilities.h"
  72. #endif
  73.  
  74.  
  75.  
  76.  
  77. #pragma segment DrawObjects
  78. long    TGroupObj(TreeObjHndl hndl, short message, long data)
  79. {
  80. #if VH_VERSION
  81.     char    *cptr;
  82.     Rect    rct;
  83. #endif
  84.  
  85.     switch (message) {
  86.         case INITMESSAGE:        /* For these messages, the TRect behavior is what we want. */
  87.         case FREEMESSAGE:
  88.         case COPYMESSAGE:
  89.         case UNDOMESSAGE:
  90.         case CONVERTMESSAGE:
  91.         case FREADMESSAGE:
  92.         case FWRITEMESSAGE:
  93.         case HREADMESSAGE:
  94.         case HWRITEMESSAGE:
  95.         case GETBBOXMESSAGE:
  96.         case SETBBOXMESSAGE:
  97.         case SECTBBOXMESSAGE:
  98.         case TARGETMESSAGE:
  99.         case CLICKMESSAGE:
  100.         case SETSELECTMESSAGE:
  101.         case GETSELECTMESSAGE:
  102.             return(TRectObj(hndl, message, data));
  103.             break;
  104.  
  105.         case HITTESTMESSAGE:
  106.             return(0L);                /* Groups can not directly be hit. */
  107.             break;
  108.  
  109.         case GETRGNMESSAGE:
  110.             return((long)NewRgn());    /* The region is used for hit-testing, so return an empty rgn. */
  111.             break;
  112.  
  113.         case DRAWMESSAGE:
  114.             if (data == DRAWSELECT)
  115.                 TRectObj(hndl, message, data);
  116.                     /* Draw the selection indicators, bu the group has no body. */
  117.             break;
  118.  
  119. #if VH_VERSION
  120.         case VHMESSAGE:
  121.             cptr = ((VHFormatDataPtr)data)->data;
  122.             ccatchr(cptr, 13, 2);
  123.             ccat   (cptr, "$10: TGroupObj:");
  124.             ccatchr(cptr, 13, 1);
  125.             ccat   (cptr, "  $00: selected = ");
  126.             ccatdec(cptr, mDerefGroup(hndl)->selected);
  127.             ccatchr(cptr, 13, 1);
  128.             rct = mDerefGroup(hndl)->group;
  129.             ccat   (cptr, "  $02: group    = ($");
  130.             ccathex(cptr, 0, 4, 4, rct.top);
  131.             ccat   (cptr, ",$");
  132.             ccathex(cptr, 0, 4, 4, rct.left);
  133.             ccat   (cptr, ",$");
  134.             ccathex(cptr, 0, 4, 4, rct.bottom);
  135.             ccat   (cptr, ",$");
  136.             ccathex(cptr, 0, 4, 4, rct.right);
  137.             ccat   (cptr, ")");
  138.             return(true);
  139.             break;
  140. #endif
  141.  
  142.         default:
  143.             break;
  144.     }
  145.  
  146.     return(noErr);
  147. }
  148.  
  149.  
  150.  
  151.